<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <label>
      <input type="checkbox" />
      <div class="switch">
        <div class="dot"></div>
      </div>
    </label>
    <style>
      input {
        display: none;
      }
      .switch {
        width: 70px;
        height: 30px;
        background-color: gray;
        border-radius: 30px;
        display: table;
        /* 解决外边距外溢 */
        transition: all 0.3s;
        overflow: hidden;
      }
      .switch .dot {
        width: 26px;
        height: 26px;
        background-color: white;
        border-radius: 50%;
        margin: 2px;
        box-sizing: border-box;
        transition: inherit;
        position: relative;
      }
      .switch .dot::before,
      .switch .dot::after {
        width: 26px;
        height: 26px;
        line-height: 26px;
        position: absolute;
        text-align: center;
        color: white;
        font-size: 12px;
        /* background-color: lightblue; */
      }
      .switch .dot::before {
        content: "ON";
        left: -26px;
      }
      .switch .dot::after {
        content: "OFF";
        left: 26px;
      }
      /* .switch.active .dot {
            transform: translateX(60px);
        } */

      /* input:checked {
        width: 50px;
        height: 50px;
      } */
      input:checked + .switch {
        background-color: orange;
      }
      input:checked + .switch .dot {
        transform: translateX(40px);
      }
    </style>

    <div>UIYTTRR</div>
  </body>
</html>
